home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s1.arc
/
DODISPLA.MOD
< prev
next >
Wrap
Text File
|
1987-08-12
|
16KB
|
451 lines
(*----------------------------------------------------------------------*)
(* Do_Display_Action --- interpret display escape sequence *)
(*----------------------------------------------------------------------*)
FUNCTION Do_Display_Action( Ch : CHAR; VAR Done : BOOLEAN ) : BOOLEAN;
(*----------------------------------------------------------------------*)
(* *)
(* Function: Do_Display_Action *)
(* *)
(* Purpose: Interprets and executes display escape sequence *)
(* *)
(* Calling sequence: *)
(* *)
(* B := Do_Display_Action( Ch : CHAR ) : BOOLEAN; *)
(* *)
(* Ch --- Character to act upon *)
(* B --- TRUE if display action completed *)
(* *)
(* Calls: Scroll *)
(* Get_Async_Integer *)
(* *)
(*----------------------------------------------------------------------*)
VAR
X: INTEGER;
Y: INTEGER;
B: BOOLEAN;
I: INTEGER;
C: INTEGER;
LABEL
LCursorUp, LCursorDown, LCursorLeft, LCursorRight,
LClearScr, LClearScrH, LClearEOS, LClearSCur,
LClearLine,
LClearEOL, LClearLCur, LCursorHome, LInsertCharA,
LInsertCharB, LInsertLineA, LInsertLineB, LDeleteChar,
LDeleteLine, LStartInsert, LEndInsert, LNormalVideo,
LReverseVideo, LStartBlink, LEndBlink, LStartUnderline,
LEndUnderline, LStartBold, LEndBold,
LStartDim, LEndDim, LReverseIndex,
LPrintLine, LPrintPage, LCursorPosVT52, LStartAltKey,
LEndAltKey, LStartAutoPrint, LEndAutoPrint, LSetTab,
LClearTab, LDisplayChar, LStartPrintControl,
LEndPrintControl, LIdentifyVT52,
LStartGraphicsMode,
LEndGraphicsMode, LTV950Video, LSwallow,
LCursorPosH, LCursorPosV,
LStartVT52HoldScreen,
LEndVT52HoldScreen,
LEnterVT100, LEnterVT52,
LExecPCCommands, LSendMahoneyOn,
LEnterState1, LEnterState2, LEnterState3, LEnterState4,
LEnterState5,
LIndex, LVT52HT, LVT52LF,
LNotDone, LEndCase;
BEGIN (* Do_Display_Action *)
X := WhereX;
Y := WhereY;
B := TRUE;
IF ( Ch = CHR( 0 ) ) THEN
ELSE IF ( Ch = ^[ ) THEN
BEGIN
Escape_Mode := TRUE;
B := FALSE;
END
ELSE IF ( ( ORD( Ch ) < 32 ) OR Escape_Mode ) THEN
BEGIN
I := ORD( Display_Action_Ptr[Display_Action_State]^[ Ch ] );
{
CASE Display_Action_Ptr[Display_Action_State]^[ Ch ] OF
}
INLINE(
$8B/$9E/>I { MOV BX,[BP+>I] ;Pick up ORD(Action)}
/$89/$D8 { MOV AX,BX ;Action}
/$D1/$E3 { SHL BX,1 ;Action * 2}
/$01/$C3 { ADD BX,AX ;Action * 3}
/$B8/>*+6 { MOV AX,>*+6 ;Address of first GOTO}
/$01/$C3 { ADD BX,AX ;Add offset of command}
/$FF/$E3 { JMP BX ;Branch to proper GOTO}
);
GOTO LCursorUp;
GOTO LCursorDown;
GOTO LCursorLeft;
GOTO LCursorRight;
GOTO LClearScr;
GOTO LClearScrH;
GOTO LClearEOS;
GOTO LClearSCur;
GOTO LClearLine;
GOTO LClearEOL;
GOTO LClearLCur;
GOTO LCursorHome;
GOTO LInsertCharA;
GOTO LInsertCharB;
GOTO LInsertLineA;
GOTO LInsertLineB;
GOTO LDeleteChar;
GOTO LDeleteLine;
GOTO LStartInsert;
GOTO LEndInsert;
GOTO LNormalVideo;
GOTO LReverseVideo;
GOTO LStartBlink;
GOTO LEndBlink;
GOTO LStartUnderline;
GOTO LEndUnderline;
GOTO LStartBold;
GOTO LEndBold;
GOTO LStartDim;
GOTO LEndDim;
GOTO LReverseIndex;
GOTO LPrintLine;
GOTO LPrintPage;
GOTO LCursorPosVT52;
GOTO LStartAltKey;
GOTO LEndAltKey;
GOTO LStartAutoPrint;
GOTO LEndAutoPrint;
GOTO LSetTab;
GOTO LClearTab;
GOTO LDisplayChar;
GOTO LStartPrintControl;
GOTO LEndPrintControl;
GOTO LIdentifyVT52;
GOTO LStartGraphicsMode;
GOTO LEndGraphicsMode;
GOTO LTV950Video;
GOTO LSwallow;
GOTO LCursorPosH;
GOTO LCursorPosV;
GOTO LStartVT52HoldScreen;
GOTO LEndVT52HoldScreen;
GOTO LEnterVT100;
GOTO LEnterVT52;
GOTO LExecPCCommands;
GOTO LSendMahoneyOn;
GOTO LEnterState1;
GOTO LEnterState2;
GOTO LEnterState3;
GOTO LEnterState4;
GOTO LEnterState5;
GOTO LIndex;
GOTO LVT52HT;
GOTO LVT52LF;
(* Display character as is *)
LDisplayChar: Display_Character( Character_Set_Ptr^[Ch] );
GOTO LEndCase;
(* Move cursor up one line *)
LCursorUp: IF ( Y > 1 ) THEN
GoToXY( X , Y - 1 );
GOTO LEndCase;
(* Move cursor down one line *)
LCursorDown: IF ( Y < Ansi_Last_Line ) THEN
GoToXY( X , Y + 1 );
GOTO LEndCase;
(* Move cursor left one column *)
LCursorLeft: IF ( X > 1 ) THEN
GoToXY( X - 1 , Y );
GOTO LEndCase;
(* Move cursor right one column *)
LCursorRight: IF ( X < Max_Screen_Col ) THEN
GoToXY( X + 1 , Y );
GOTO LEndCase;
(* Clear screen *)
LClearScr: BEGIN
Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
ForeGround_Color, BackGround_Color );
FillChar( Line_Attributes, 25, 0 );
GoToXY( X , Y );
END;
GOTO LEndCase;
(* VT52 tabs *)
LVT52HT: Handle_Tab( Tab_Stops , Number_Tab_Stops );
GOTO LEndCase;
(* VT52 line feeds *)
LVT52LF: Do_VT52_LineFeeds( Ch );
GOTO LEndCase;
LEnterState1: Display_Action_State := 1;
GOTO LEndCase;
LEnterState2: Display_Action_State := 2;
GOTO LEndCase;
LEnterState3: Display_Action_State := 3;
GOTO LEndCase;
LEnterState4: Display_Action_State := 4;
GOTO LEndCase;
LEnterState5: Display_Action_State := 5;
GOTO LEndCase;
(* Clear screen and home cursor *)
LClearScrH: BEGIN
Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
ForeGround_Color, BackGround_Color );
FillChar( Line_Attributes, 25, 0 );
GoToXY( 1 , 1 );
END;
GOTO LEndCase;
(* Clear cursor to end of screen *)
LClearEOS: BEGIN
ClrEol;
FOR I := ( Y + 1 ) TO Ansi_Last_Line DO
BEGIN
GoToXY( 1 , I );
ClrEol;
Line_Attributes[I] := 0;
END;
GoToXY( X , Y );
END;
GOTO LEndCase;
(* Clear start of screen to current *)
(* cursor position *)
LClearSCur: BEGIN
IF ( Y > 1 ) THEN
Scroll( 1, Y - 1, 1, Max_Screen_Col, 0,
ForeGround_Color, BackGround_Color );
GoToXY( 1 , Y );
FOR I := 1 TO X DO
WRITE(' ');
FOR I := 1 TO Y DO
Line_Attributes[I] := 0;
END;
GOTO LEndCase;
(* Clear entire line *)
LClearLine: BEGIN
GoToXY( 1 , Y );
ClrEol;
GoToXY( X , Y );
Line_Attributes[Y] := 0;
END;
GOTO LEndCase;
(* Clear cursor to end of line *)
LClearEOL: ClrEol;
GOTO LEndCase;
(* Clear start of line to cursor *)
LClearLCur: BEGIN
GoToXY( 1 , Y );
FOR I := 1 TO X DO
WRITE(' ');
END;
GOTO LEndCase;
(* Move cursor to top left hand corner *)
LCursorHome: GoToXY( 1 , 1 );
GOTO LEndCase;
(* Reverse index *)
LReverseIndex: BEGIN
IF ( Y > 1 ) THEN
GoToXY( X , Y - 1 )
ELSE
Scroll( 1, Max_Screen_Line - 1, 1, Max_Screen_Col,
-1,
ForeGround_Color, BackGround_Color );
END;
GOTO LEndCase;
(* Index *)
LIndex: Display_Character( ^J );
GOTO LEndCase;
LTV950Video: BEGIN
Async_Receive_With_TimeOut( 5 , C );
IF ( C <> TimeOut ) THEN
CASE CHR( C ) OF
'0': ;
'2': ;
'4': ;
'8': ;
END (* CASE *);
END;
GOTO LEndCase;
LStartGraphicsMode : BEGIN
Graphics_Mode := TRUE;
Character_Set_Ptr := Display_Char_Set_Ptr[2];
END;
GOTO LEndCase;
LEndGraphicsMode : BEGIN
Graphics_Mode := FALSE;
Character_Set_Ptr := Display_Char_Set_Ptr[1];
END;
GOTO LEndCase;
LIdentifyVT52 : Async_Send_String( ^[ + '/Z' );
GOTO LEndCase;
LPrintPage: Print_Screen;
GOTO LEndCase;
(* Toggle reverse video *)
LReverseVideo: BEGIN
I := ForeGround_Color;
ForeGround_Color := BackGround_Color;
BackGround_Color := I;
Global_Text_Attribute := 16 * ( BackGround_Color AND 7 ) + ForeGround_Color;
TextColor( ForeGround_Color );
TextBackGround( BackGround_Color );
END;
GOTO LEndCase;
LStartDim : LowVideo;
GOTO LEndCase;
LEndDim : HighVideo;
GOTO LEndCase;
(* Move to screen position in VT52 format *)
LCursorPosVT52: BEGIN
OldX := NewX;
OldY := NewY;
Get_Async_Integer( NewY );
Get_Async_Integer( NewX );
NewY := MAX( 1 , MIN( NewY , Max_Screen_Line - 1 ) );
NewX := MAX( 1 , MIN( NewX , Max_Screen_Col ) );
GoToXY( NewX, NewY );
END;
GOTO LEndCase;
LStartAltKey: Alt_Keypad_Mode := ON;
GOTO LEndCase;
LEndAltKey : Alt_Keypad_Mode := OFF;
GOTO LEndCase;
LStartAutoPrint: Auto_Print_Mode := ON;
GOTO LEndCase;
LEndAutoPrint: Auto_Print_Mode := OFF;
GOTO LEndCase;
LStartPrintControl: Printer_Ctrl_Mode := ON;
GOTO LEndCase;
LEndPrintControl : Printer_Ctrl_Mode := OFF;
GOTO LEndCase;
LStartVT52HoldScreen: Hold_Screen_Mode := ON;
GOTO LEndCase;
LEndVT52HoldScreen : Hold_Screen_Mode := OFF;
GOTO LEndCase;
LEnterVT100: BEGIN (* Enter VT100 mode *)
Terminal_To_Emulate := VT100;
Done := TRUE;
END;
GOTO LEndCase;
(* Indicate AutoDownload possible *)
LSendMahoneyOn : IF Mahoney_On THEN Async_Send_String( 'EXECPC2' );
GOTO LEndCase;
LExecPCCommands: IF Mahoney_On THEN Exec_PC_Commands;
GOTO LEndCase;
LInsertCharA:
LInsertCharB:
LInsertLineA:
LInsertLineB:
LDeleteChar:
LDeleteLine:
LStartInsert:
LEndInsert:
LNormalVideo:
LStartBlink:
LEndBlink:
LStartUnderline:
LEndUnderline:
LStartBold:
LEndBold:
LPrintLine:
LSetTab:
LClearTab:
LSwallow:
LCursorPosH:
LCursorPosV:
LEnterVT52:
LNotDone : B := FALSE;
LEndCase : ;
END
ELSE
Display_Character( Character_Set_Ptr^[Ch] );
IF B THEN
BEGIN
Do_Display_Action := TRUE;
Escape_Mode := FALSE;
END
ELSE
Do_Display_Action := FALSE;
END (* Do_Display_Action *);